package org.lucas.configuration;

import lombok.extern.slf4j.Slf4j;
import org.lucas.properties.QueryApiProperty;
import org.lucas.utils.PhoneLocationQueryUtil;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class OpenApiConfiguration {

    //使用单例模式创建唯一连接，减少资源消耗
    @Bean
    @ConditionalOnMissingBean
    public PhoneLocationQueryUtil phoneLocationQueryUtil(QueryApiProperty queryApiProperty) {
        log.info("注册LMHZ-查询接口客户端");
        return new PhoneLocationQueryUtil(
                queryApiProperty.getAccessUrl(),
                queryApiProperty.getSecretId(),
                queryApiProperty.getSecretKey()
        );
    }
}
